package org.demo.five;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 
 * @author  
 * @date    2010-10-24
 * @file    org.demo.five.Person.java
 */
public class Person implements Iterable<Person>{
	private String firstName;
    private String lastName;
    private int age;
    private Person spouse;
    private List<Person> children = new ArrayList<Person>();
    
	public Person(String fn,String ln,int a,Person... kids){
        this.firstName = fn;
        this.lastName = ln;
        this.age = a;
        for (Person child : kids){
        	children.add(child);
        }
    }
    public String getFirstName(){return firstName;}
    public String getlastName(){return lastName;}
    public int getAge(){return age;}
    public Person getSpouse(){return spouse;}
    public List<Person> getChildren(){return children;}
    
    public void setFirstName(String value){firstName = value;}
    public void setLastName(String value){lastName = value;}
    public void setAge(int value){age = value;}
    public void setSpouse(Person value){spouse = value;}
    
    public Iterator<Person> iterator() {
		return children.iterator();
	}
    
    @Override
    public int hashCode() {
    	return firstName.hashCode() & lastName.hashCode() & age;
    }
	public String toString(){
        return "[Person: firstName=" + firstName
        + " lastName=" + lastName
        + " age=" + age
        + "]";
    }
}
